﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SLLottery.LotterySrv;
namespace SLLottery.Common
{
    public class BonusCalc
    {
        public static double GetMaxScale()
        {
            if (Constant.Multiple == 1000)
                return Constant.BaseScale;
            User user = App.Session[Constant.USERINFO_SESSION] as User;
            return ((user.Bonus / 0.1) * 2 + Constant.BaseScale) / Constant.Multiple;
        }
        public static double GetMinScale()
        {
            return Constant.BaseMinScale / Constant.Multiple;
        }
        public static double GetMaxBonusPct()
        {
            double MaxScale = GetMaxScale();
            double MinScale = GetMinScale();
            return ((MaxScale - MinScale) / 0.1 / 2 / 100) * Constant.Multiple;
        }
        public static string GetScale(double Bonus)
        {
            User user = App.Session[Constant.USERINFO_SESSION] as User;
            if (Bonus == user.Bonus)
            {
                if (Constant.Multiple == 100)
                    return ((Constant.BaseScale / Constant.Multiple)).ToString("F2");
                else if (Constant.Multiple == 10)
                    return ((Constant.BaseScale / Constant.Multiple)).ToString("F1");
                else if (Constant.Multiple == 1)
                    return ((Constant.BaseScale / Constant.Multiple)).ToString("F0");
                else
                    return (Constant.MaxScale).ToString("F2");
            }
            else
            {
                if (Constant.Multiple == 100)
                    return ((Constant.MaxScale - Bonus * 20 / Constant.Multiple)).ToString("F2");
                else if (Constant.Multiple == 10)
                    return ((Constant.MaxScale - Bonus * 20 / Constant.Multiple)).ToString("F1");
                else if (Constant.Multiple == 1)
                    return ((Constant.MaxScale - Bonus * 20 / Constant.Multiple)).ToString("F0");
                else
                    return (Constant.MaxScale).ToString("F2");
            }
        }
        public static string GetBonus(double Bonus)
        {
            User user = App.Session[Constant.USERINFO_SESSION] as User;
            if (Bonus == user.Bonus)
            {
                if (Constant.Multiple == 100)
                    return (Constant.BaseScale / Constant.Multiple / 2).ToString("F2");
                else if (Constant.Multiple == 10)
                    return (Constant.BaseScale / Constant.Multiple / 2).ToString("F1");
                else if (Constant.Multiple == 1)
                    return (Constant.BaseScale / Constant.Multiple / 2).ToString("F0");
                else
                    return (Constant.MaxScale / 2).ToString("F2");
            }
            else
            {
                if (Constant.Multiple == 100)
                    return ((Constant.MaxScale - Bonus * 20 / Constant.Multiple) / (2)).ToString("F2");
                else if (Constant.Multiple == 10)
                    return ((Constant.MaxScale - Bonus * 20 / Constant.Multiple) / (2)).ToString("F1");
                else if (Constant.Multiple == 1)
                    return ((Constant.MaxScale - Bonus * 20 / Constant.Multiple) / (2)).ToString("F0");
                else
                    return (Constant.MaxScale / 2).ToString("F2");
            }
        }
    }
}
